<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<ui:composition template="../templates/layout.xhtml">
	<ui:define name="content">
		<h:form prependId="false" id="growlForm">
			<p:growl id="growl" showDetail="false" />
		</h:form>
		<h:form prependId="false" id="dataForm">
			<p:panel id="data" toggleable="true" toggleSpeed="250">
				<f:facet name="header">
					<h:outputText value="#{provinciaBean.name}" />
				</f:facet>



				<h:panelGrid columns="1">
					<p:fieldset legend="Registrar una Categoría" toggleable="true"
						toggleSpeed="300">
						<h:panelGrid id="grid" columns="3">

							<h:outputLabel for="selectedDepartamento"
								style="font-weight: bold;" value="Seleccione un Departamento:" />
							<p:autoComplete value="#{provinciaBean.provincia.departamentoCodDepartamento}"
								id="selectedDepartamento"
								dropdown="true"
								completeMethod="#{provinciaBean.completeDepartamentoCodDepartamento}" var="departamentoCodDepartamento"
								itemLabel="#{departamentoCodDepartamento.descripcion}" itemValue="#{departamentoCodDepartamento}" converter="com.pe.bean.converter.DepartamentoConverter">

							</p:autoComplete>
							<p:message for="selectedDepartamento" display="icon" />


							<h:outputLabel for="descripcionProvincia"
								style="font-weight: bold;" value="Descripción:" />

							<p:inputText id="descripcionProvincia"
								requiredMessage="Ingrese la descripción de la Provincia"
								value="#{provinciaBean.provincia.descripcion}" required="true"
								style="width:200px" />
							<p:message for="descripcionProvincia" display="icon" />
						</h:panelGrid>
						<p:row>
							<p:column>
								<p:commandButton id="registrarProvinciaButton"
									value="#{messages.label_save}"
									update=":growlForm:growl data list"
									actionListener="#{provinciaBean.persist}" />
							</p:column>
						</p:row>
					</p:fieldset>
				</h:panelGrid>

				<h:outputFormat id="noRecordsFound"
					value="#{messages.label_no_records_found}"
					rendered="#{!provinciaBean.dataVisible}">
					<f:param value="Provincias" />
				</h:outputFormat>
				<p:dataTable id="list" value="#{provinciaBean.allProvincias}"
					var="provincia" rendered="#{provinciaBean.dataVisible}"
					resizableColumns="false" paginator="true"
					paginatorTemplate=" {CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="5,10,25,50" rows="10">
					<p:columns value="#{provinciaBean.columns}" var="column"
						columnIndexVar="colIndex">
						<f:facet name="header">
							<h:outputText value="#{applicationBean.getColumnName(column)}" />
						</f:facet>
						<h:outputText value="#{provincia[column]}" />
					</p:columns>
					<p:column styleClass="action-column">
						<f:facet name="header">
							<h:outputText value="Actions" />
						</f:facet>
						<p:commandButton id="viewButton" icon="ui-icon-zoomin"
							update=":viewForm:viewPanelGrid" oncomplete="viewDialog.show()"
							title="#{messages.label_view}">
							<f:setPropertyActionListener value="#{provincia}"
								target="#{provinciaBean.provincia}" />
						</p:commandButton>
						<p:tooltip for="viewButton" value="#{messages.label_view}"
							showEffect="fade" hideEffect="fade" />
						<p:commandButton id="editButton" icon="ui-icon-pencil"
							update=":editForm:editPanelGrid" action="#{provinciaBean.onEdit}"
							oncomplete="editDialog.show()" title="#{messages.label_edit}">
							<f:setPropertyActionListener value="#{provincia}"
								target="#{provinciaBean.provincia}" />
						</p:commandButton>
						<p:tooltip for="editButton" value="#{messages.label_edit}"
							showEffect="fade" hideEffect="fade" />
						<p:commandButton id="deleteButton" icon="ui-icon-trash"
							oncomplete="deleteDialog.show()" title="#{messages.label_delete}">
							<f:setPropertyActionListener value="#{provincia}"
								target="#{provinciaBean.provincia}" />
						</p:commandButton>
						<p:tooltip for="deleteButton" value="#{messages.label_delete}"
							showEffect="fade" hideEffect="fade" />
					</p:column>
				</p:dataTable>
			</p:panel>
		</h:form>
		<p:dialog id="createDialog"
			header="#{messages.label_create} Provincia" modal="true"
			widgetVar="createDialog" dynamic="true"
			visible="#{provinciaBean.createDialogVisible}" resizable="true"
			maximizable="true" showEffect="fade" hideEffect="explode">
			<p:ajax event="close" update=":dataForm:data"
				listener="#{provinciaBean.handleDialogClose}" />
			<p:outputPanel id="createPanel">
				<h:form id="createForm" enctype="multipart/form-data">
					<h:panelGrid id="createPanelGrid" columns="3"
						binding="#{provinciaBean.createPanelGrid}" styleClass="dialog"
						columnClasses="col1,col2,col3" />
					<p:commandButton id="createSaveButton"
						value="#{messages.label_save}" action="#{provinciaBean.persist}"
						update="createPanelGrid :growlForm:growl" />
					<p:commandButton id="createCloseButton"
						value="#{messages.label_close}" onclick="createDialog.hide()"
						type="button" />
				</h:form>
			</p:outputPanel>
		</p:dialog>
		<p:dialog id="editDialog" header="#{messages.label_edit} Provincia"
			modal="true" widgetVar="editDialog" dynamic="true" resizable="true"
			maximizable="true" showEffect="fade" hideEffect="explode">
			<p:ajax event="close" update=":dataForm:data"
				listener="#{provinciaBean.handleDialogClose}" />
			<p:outputPanel id="editPanel">
				<h:form id="editForm" enctype="multipart/form-data">
					<h:panelGrid id="editPanelGrid" columns="3"
						binding="#{provinciaBean.editPanelGrid}" styleClass="dialog"
						columnClasses="col1,col2,col3" />
					<p:commandButton id="editSaveButton" value="#{messages.label_save}"
						action="#{provinciaBean.persist}"
						update="editPanelGrid :growlForm:growl" />
					<p:commandButton id="editCloseButton"
						value="#{messages.label_close}" onclick="editDialog.hide()"
						type="button" />
				</h:form>
			</p:outputPanel>
		</p:dialog>
		<p:dialog id="viewDialog" header="#{messages.label_view} Provincia"
			modal="true" widgetVar="viewDialog" dynamic="true" resizable="true"
			maximizable="true" showEffect="fade" hideEffect="explode">
			<p:outputPanel id="viewPanel">
				<h:form id="viewForm" enctype="multipart/form-data">
					<h:panelGrid id="viewPanelGrid" columns="2"
						binding="#{provinciaBean.viewPanelGrid}" styleClass="dialog"
						columnClasses="col1,col2" />
					<p:commandButton id="viewCloseButton"
						value="#{messages.label_close}" onclick="viewDialog.hide()"
						type="button" />
				</h:form>
			</p:outputPanel>
		</p:dialog>
		<p:confirmDialog id="deleteDialog" widgetVar="deleteDialog"
			message="#{messages.label_delete_record}" showEffect="fade"
			hideEffect="explode" header="#{messages.label_confirm_deletion}"
			severity="alarm">
			<p:outputPanel id="deletePanel">
				<h:form id="deleteForm">
					<p:commandButton id="deleteYesButton" value="#{messages.label_yes}"
						action="#{provinciaBean.delete}"
						update=":dataForm:data :growlForm:growl"
						oncomplete="deleteDialog.hide()" />
					<p:commandButton id="deleteNoButton" value="#{messages.label_no}"
						onclick="deleteDialog.hide()" type="button" />
				</h:form>
			</p:outputPanel>
		</p:confirmDialog>
	</ui:define>
</ui:composition>
</html>